<%--
  @author Nuwan Koggalahewa
  --%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<script type="text/javascript">

    $(function() {
        if($("input#searchSelected").val() == "true"){
            $('#land-table1').dataTable({
                aaSorting: [],
                "sPaginationType": "full_numbers",
                "bDestroy": true,
                "oLanguage": {
                    "sZeroRecords": $('#no-record').val(),
                    "sLengthMenu": $('#display').val() + " _MENU_ " + $('#records').val(),
                    "sSearch": $('#search').val(),
                    "sInfo": $('#showing').val() + " _START_ " + $('#to').val() + " _END_ " + $('#of').val() + " _TOTAL_ " + $('#entries').val(),
                    "sInfoEmpty": $('#no-record').val(),
                    "oPaginate": {
                        "sFirst": $('#first').val(),
                        "sLast": $('#last').val(),
                        "sNext": $('#next').val(),
                        "sPrevious": $('#previous').val()
                    }
                },
                "fnDrawCallback": function() {
                    if ($('.dataTables_paginate span span.paginate_button').size()) {
                        $('.dataTables_paginate')[0].style.display = "block";
                    } else {
                        $('.dataTables_paginate')[0].style.display = "none";
                    }
                }
            });
        }
    });

</script>

<div id="detailLandWithSearch" >
    <table id="detailLandWithSearchTable">
        <s:form>
            <tr>
                <td>
                    <s:label value="%{getText('name_of_the_land.label')}"></s:label>
                </td>
                <td>
                    <s:textfield id="landNameSearchText" name="searchText1"></s:textfield>
                    <s:hidden name="pageNo"/>
                </td>
            </tr>
            <tr>
                <td>
                    <s:label value="%{getText('plan_no.label')}"></s:label>
                </td>
                <td>
                    <s:textfield id="landNumber" name="searchText2"></s:textfield>
                </td>
            </tr>
            <tr>
                <td>
                    <s:label value="%{getText('lot_no.label')}"></s:label>
                </td>
                <td>
                    <s:textfield id="lotNumber" name="searchText3"></s:textfield>
                </td>
            </tr>
            <tr>
                <td>
                    <s:label value="%{getText('holder_name.label')}"></s:label>
                </td>
                <td>
                    <s:textfield id="holderName" name="searchText4"></s:textfield>
                </td>
            </tr>
            <tr>
                <table>
                    <tr>
                        <td>

                            <s:submit action="searchDetailedLandBySearchText"  id="searchTextButton" value="%{getText('search.label')}" />
                        </td>
                        <td>
                            <s:if test="pageNo > 1">
                                <s:submit action="searchDetailedLandUsingSearchTextBackPageId" name="back"
                                          value="%{getText('previous.label')}"/>
                            </s:if>
                        </td>
                        <td>
                            <s:if test="showNextButton == true">
                                <s:submit action="searchDetailedLandUsingSearchTextNextPageId" name="next"
                                          value="%{getText('next.label')}"></s:submit>
                            </s:if>
                        </td>
                    </tr>
                </table>
            </tr>
        </s:form>
    </table>


</div>

<div id="resultsTable">
    <s:if test="landList.size > 0">

        <table id="land-table1" class="width-100 margin-10-auto table land-table1">
            <thead>
            <tr>
                <th><s:label value="%{getText('reference_no.label')}"/></th>
                <th><s:label value="%{getText('name_of_the_land.label')}"/></th>
                <th><s:label value="District"/></th>
                <th><s:label value="%{getText('lot_no.label')}"/></th>
                <%--<th><s:label value="%{getText('extent_perches.label')}"/></th>--%>
                    <%--<th><s:label value="%{getText('alienation_status.label')}"/></th>--%>
                    <%--   <th><s:label value="%{getText('approval_state.label')}"/></th>--%>
                <th><s:label value="%{getText('action.label')}"/></th>

            </tr>
            </thead>
            <tbody>
            <s:iterator status="lands" value="landList">

                <tr>
                    <td width="80px"><s:property value="id"/></td>
                    <td width="80px">
                        <s:if test="%{migrationState.ordinal() == 2}">
                            <img src="${pageContext.request.contextPath}/images/excel-migrated.png" style="border:none; width:15px; height:15px;" alt="Migrated Record from Excel"/>
                        </s:if>
                        <s:elseif test="%{migrationState.ordinal() == 1}">
                            <img src="${pageContext.request.contextPath}/images/access-migrated.png" style="border:none; width:15px; height:15px;" alt="Migrated Record from Access"/>
                        </s:elseif>
                        <s:property value="landFileNumber"/>
                    </td>
                    <td width="80px"><s:property value="district.enDistrictName"/></td>
                    <td width="80px"><s:property value="lotNumber"/></td>

                    <%--<td width="80px" class="center-align">
                        <s:property value="landExtent"/>
                    </td>--%>
                    <td width="80px" class="center-align">
                        <a href="loadRailwayLandDetails.do?editMode=1&landId=<s:property value="id"/>"/>
                        <img src="${pageContext.request.contextPath}/images/detailed-form.png"
                             style="border:none; width:25px; height:25px;" />

                    </td>
                </tr>

            </s:iterator>
            </tbody>
        </table>
    </s:if>
</div>

